
from fastapi import APIRouter
from api.deps import SessionDep
from schemas.driver_schema import DriverCreate,DriverPublic
from services import driver_service
from schemas.response_schema import R
router = APIRouter()

@router.post("/",summary="创建新司机",response_model=DriverPublic)
async def create_dd_router(*,session:SessionDep,
                           driver:DriverCreate):
    "创建新司机"
    db_driver = await driver_service.create_driver(session=session,driver=driver)
    return db_driver

@router.get("/{license_plate}",summary="获取司机信息",response_model=R[DriverPublic])
async def get_driver_license_plate(*,session:SessionDep,license_plate:str):
    "通过司机车牌号查询司机信息"
    db_driver = await driver_service.find_driver_license_plate(session=session,license_plate=license_plate)
    return R.success(db_driver)